package com.deductive.service.special.impl;

import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.lang.tree.TreeNodeConfig;
import cn.hutool.core.lang.tree.TreeUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.deductive.domain.special.SpecialWsfyjg;
import com.deductive.service.special.SpecialWsfyjgService;
import com.deductive.mapper.special.SpecialWsfyjgMapper;
import org.springframework.stereotype.Service;

import java.util.List;


/**
* @author 47338
* @description 针对表【special_wsfyjg(卫生防疫机构)】的数据库操作Service实现
* @createDate 2025-09-01 16:33:33
*/
@Service
public class SpecialWsfyjgServiceImpl extends ServiceImpl<SpecialWsfyjgMapper, SpecialWsfyjg>
    implements SpecialWsfyjgService {


    @Override
    public List<Tree<Object>> listTree() {
        TreeNodeConfig treeNodeConfig = new TreeNodeConfig();
        treeNodeConfig.setIdKey("id");
        treeNodeConfig.setNameKey("name");
        treeNodeConfig.setParentIdKey("parentId");
        List<SpecialWsfyjg> list = this.list();
        List<Tree<Object>> treeList = TreeUtil.build(list, 0, treeNodeConfig, (specialHospital, tree) -> {
            tree.setId(specialHospital.getId()); // 设置节点ID
            tree.setName(specialHospital.getChineseName()); // 设置节点名称（显示文本）
            tree.setParentId(specialHospital.getParentId());
            tree.putExtra("countryName", specialHospital.getCountryName());
            tree.putExtra("englishName", specialHospital.getEnglishName());
            tree.putExtra("address", specialHospital.getAddress());
            tree.putExtra("overview", specialHospital.getOverview());
            tree.putExtra("affiliation", specialHospital.getAffiliation());
            tree.putExtra("epidemicPreventiOnForce", specialHospital.getEpidemicPreventiOnForce());
            tree.putExtra("contactInformation", specialHospital.getContactinformation());
            tree.putExtra("internalInstitutions", specialHospital.getInternalinstitutions());
            tree.putExtra("website", specialHospital.getWebsite());
            tree.putExtra("lon", specialHospital.getLon());
            tree.putExtra("lat", specialHospital.getLat());
        });
        return treeList;
    }
}